﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Kaleta.Xna;
using Kaleta.Network;
using Microsoft.Xna.Framework.Graphics;
using Kaleta.Xna.Collision;
using Kaleta.Xna.Interfaces;
using Microsoft.Xna.Framework;

namespace Kaleta.Xna.Distributed
{
    /// <summary>
    /// Defines an object with Geometry(Body) and the ability to distribute properties in a network session.
    /// All public properties with Attribute 'Distribute' will be distributed once (with the call of DistributionSession.DistributeObject).
    /// If you want to distribute a property on every change, implement a getter/setter for this property.
    /// </summary>
    public abstract class DistributedSolidBody : DistributableObject, IBody, IRenderable, IUpdatable
    {
        #region Properties ignored by Distribution
       
        public Texture2D Texture { get; set; }
        public CollisionGroup CollisionGroup { get; set; }
        
        public Body Body { get; set; }
        #endregion

        #region Properties propagated by Distribution only once
        [Distribute]
        public Vector2 Position { get { return this.Body.Position; } set { this.Body.Position = value; } }

        [Distribute]
        public float Direction { get { return this.Body.Direction; } set {this.Body.Direction = value;} }

        #endregion

        public abstract void OnCollision(IBody obstacle, List<BodyShape> intersectingColliderShapes, List<BodyShape> intersectingObstacleShapes);

        public abstract void Update(GameTime gameTime);

        public abstract void Draw(SpriteBatch batch);
    }
}
